/******************************************************************************
**                                                                           **
**                 Proprietary and Confidential Information                  **
**                                                                           **
**                 Copyright (c) Conexant, Inc. Unpublished                  **
**                                                                           **
** This source code and the algorithms implemented therein constitute        **
** confidential information and may compromise trade secrets of Conexant,    **
** Inc. or its associates, and any unauthorized use thereof is prohibited.   **
**                                                                           **
******************************************************************************/
#ifndef _resmgr_h_
# define _resmgr_h_
/**************************************************************************//**
*  @file resmgr.h
*  This header defines the information stored in the lock manager.
*
*  DEVELOPER NOTE:
*  When new processes which can lock resources are added to the ACL,
*  the ID for the new process must be added to the defines here.
*
*  As resources are added, they must be defined in here.
******************************************************************************/
/******************************************************************************
*  FILE FORMAT: <PUBLIC>
*      1. INCLUDES 
*      2. ENUMERATIONS 
*      3. DEFINES
*      4. STRUCTURES
*      5. GLOBALS
*      6. PUBLIC FUNCTION PROTOTYPES
******************************************************************************/
/******************************************************************************
*  1. INCLUDES
******************************************************************************/
#include "dc_type.h"
/******************************************************************************
*  2. ENUMERATIONS
******************************************************************************/
/// Commands which are given to the ResourceMgr function
typedef enum
{
    LOCK_ALL  = 0,      /// lock all or NONE of the resources asked for
    LOCK_ALL_WAIT,      /// lock all the resources and wait until done
    LOCK_CLEAR,         /// unlock all resources owned by this locker
    LOCK_UNLOCK,        /// unlock specific resources
    LOCK_WHO,           /// find who owns the resource
    LOCK_ISME           /// Determine if caller owns the resource.
} LOCK_CMD_t;

/// List of "units" which can lock resources
typedef enum
{
    U_VOID    = 0,      /// No unit.  NULL return.
    U_UI,               /// User Interface Unit
    U_FX,               /// Fax Unit
    U_US,               /// USB Unit
    U_LC,               /// Local Copy Unit
    U_PCSC,             /// PC Scan Unit
    U_PCPR,             /// PC Print Unit
    U_PH,               /// Photo Print Unit
    U_PM,               /// Printer Maint
    U_PW,               /// Power Unit
    U_DBG,              /// debug (Dbgmon) process
    U_RPT,              /// System Report Unit (Text Generation)
    U_EM,               /// Scan to Email Unit
    U_SYSMAN,           /// System Manager
    U_FP,               /// Form Parser Unit
    U_SF,               /// Scan to file unit
    U_UPNP,             /// UPNP print client

    U_NONE,             /// NO unit, this is a return value
    U_MIX,              /// more than one unit, this is a return value
    U_ANY               /// ANY unit, this is a return value
} UNIT_ID_t;

/// Resource list
typedef enum
{
    R_SCU   = 0x40000000,      /// Scan unit
    R_PRU   = 0x20000000,      /// Print unit
    R_ROU   = 0x10000000,      /// Rotate unit
    R_LCD   = 0x08000000       /// LCD Data - scan to list etc.
} RESOURCE_ID_t;
/******************************************************************************
*  3. DEFINES
******************************************************************************/
typedef char *RRC_TYPE;
/******************************************************************************
*  4. STRUCTURES
******************************************************************************/
/******************************************************************************
*  5. GLOBALS
******************************************************************************/
/******************************************************************************
*  6. PUBLIC FUNCTION PROTOTYPES
******************************************************************************/


/*************************************************************************//**
*  This routine performs the locking, unlocking, and querying of resources
*  in a system. The ACL components use this routine to guarantee a desired
*  resource is owned across multiple requests for activity.  This function 
*  is equivalent to calling ResourceMgrEx with the ownerCode set to 0.
*
*  @locker_id - The ACL identifier (who is doing)
*  @param cmd - The activity to be performed such as lock, unlock, or query
*  (what is to be done)
*  @param resource_id - The resource to be enacted on (to what resources)
*
*  @return May return an ACL identifier or a special return code.
******************************************************************************/
UNIT_ID_t ResourceMgr(UNIT_ID_t locker_id, LOCK_CMD_t cmd, RESOURCE_ID_t resource_id);


/*************************************************************************//**
*  This routine performs the locking, unlocking, and querying of resources
*  in a system. The ACL components use this routine to guarantee a desired
*  resource is owned across multiple requests for activity.
*
*  @locker_id - The ACL identifier (who is doing)
*  @param cmd - The activity to be performed such as lock, unlock, or query
*  (what is to be done)
*  @param resource_id - The resource to be enacted on (to what resources)
*  @param ownerCode - The sub-locker_id.
*
*  @return May return an ACL identifier or a special return code.
******************************************************************************/
UNIT_ID_t ResourceMgrEx(UNIT_ID_t locker_id, LOCK_CMD_t cmd, RESOURCE_ID_t resource_id, UINT32 * ownerCode);


/*************************************************************************//**
*  This routine reads from a ROM space to RAM space. The source from ROM
*  can be either a direct address or a resource identifier. The mode is set
*  by the useSrcAddr field.
*
*  @param d - Data to store in RAM
*  @param len - Number of bytes to transfer
*  @param rrc - ROM resource identifier to read from (optional)
*  @param srcAddr - ROM source address to read from (optional)
*  @param useSrcAddr - Flag to indicate whether rrc or srcAddr
******************************************************************************/
void RESMGR_ReadToRam(UINT8 *d, UINT32 len, RRC_TYPE rrc, UINT32 srcAddr, boolean useSrcAddr);
#endif /*  _resmgr_h_ */
